package com.kinghood.productcenter.common.model.enums.base;

import lombok.Getter;

/**
 * 属性值类型枚举
 *
 * @author jp
 * @date 2023/12/27
 */
@Getter
public enum AttributeValueCodeEnum {
    SELECT("SELECT", "下拉列表"),
    LEVEL_SELECT("LEVEL_SELECT", "联动层级下拉列表"),
    RADIO("RADIO", "单选框"),
    CHECK_BOX("CHECK_BOX", "复选框"),
    SINGLE_LINE("SINGLE_LINE", "单行文本框"),
    MULTILINE("MULTILINE", "多行文本框"),
    RICH_TEXT("RICH_TEXT", "富文本"),
    DATE("DATE", "日期"),
    DATE_RANGE("DATE_RANGE", "日期区间"),
    NUMERICAL("NUMERICAL", "数值"),
    NUMERICAL_RANGE("NUMERICAL_RANGE", "数值区间");

    private String code;
    private String name;

    AttributeValueCodeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String getNameByCode(String code) {
        for (AttributeValueCodeEnum myEnum : AttributeValueCodeEnum.values()) {
            if (myEnum.getCode().equals(code)) {
                return myEnum.getName();
            }
        }
        return null;
    }

    /**
     * 属性值是否为下拉选项
     *
     * @author jp
     * @date 2023/12/27
     */
    public static boolean isMulti(String code) {
        if (code.equals(CHECK_BOX.getCode()) || code.equals(LEVEL_SELECT.getCode())
                || code.equals(RADIO.getCode()) || code.equals(SELECT.getCode())) {
            return true;
        }
        return false;
    }

    /**
     * 是需要限制信息
     *
     * @param code 密码
     * @author jp
     * @date 2023/12/27
     */
    public static boolean isNeedLimitInfo(String code) {
        if (code.equals(NUMERICAL.getCode()) || code.equals(NUMERICAL_RANGE.getCode())
                || code.equals(SINGLE_LINE.getCode()) || code.equals(MULTILINE.getCode())) {
            return true;
        }
        return false;
    }
}
